import Vuex from "vuex";
import Vue from 'vue';

Vue.use(Vuex);

const store = new Vuex.Store({
    state: {
        User: {
            UserName: "未登录用户",
            UserEmail: "未登录用户",
            UserPassword: "未登录用户",
            UserAddress: "未登录用户",

            isLogin: false,
        },


    },
    mutations: {
        unLogin(state) {
            state.User.UserName = "未登录用户";
            state.User.UserEmail = "未登录用户";
            state.User.UserPassword = "未登录用户";
            state.User.UserAddress = "未登录用户";
            state.User.isLogin = false;
        },
        Login(state, UserObject) {
            state.User.UserName = UserObject.userName;
            state.User.UserEmail = UserObject.userEmail;
            state.User.UserPassword = UserObject.password;
            state.User.UserAddress = UserObject.userAddress;

            state.User.isLogin = true;
        }
    }
})

export default store;